#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
const int N = 100005;
int n, m;
struct node {
	string name;
	string group;
	int cnt;
}d[N];
bool cmp (node x, node y) {
	return x.name < y.name;
}
bool tmp;
void binary_search (int l, int r, string s) {
	if (l == r) {
		if (d[l].name == s) {
			d[l].cnt++;
			tmp = 1;
		}
		return;
	}
	int mid = (l + r) / 2;
	if (s <= d[mid].name) {
		binary_search (l, mid, s);
	} else {
		binary_search (mid + 1, r, s);
	}
}
int main() {
	std::ios::sync_with_stdio(false);
	cin >> n;
	string s1, s2;
	getline (cin, s1);
	s1 = "";
	for (int i = 1; i <= n; i++) {
		getline (cin, s1);
		getline (cin, s2);
		d[i].name = s1;
		d[i].group = s2;
		d[i].cnt = 0;
	}
	cin >> m;
	sort (d + 1, d + n + 1, cmp);
	s1 = "";
	getline (cin, s1);
	s1 = "";
	for (int i = 1; i <= m; i++) {
		getline (cin, s1);
		tmp = 0;
		binary_search (1, n, s1);
		if (!tmp) {
			d[++n].name = s1;
			d[n].group = "independent";
			d[n].cnt = 0; 
		}
	}
	string maxn;
	int maxi = -1;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (d[i].cnt > maxi) {
			maxi = d[i].cnt;
			maxn = d[i].group;
		}
	}
	for (int i = 1; i <= n; i++) {
		if (d[i].cnt == maxi) {
			ans++;
		}
	}
	if (ans > 1) {
		cout << "tie" << endl;
		return 0;
	}
	cout << maxn << endl;
	return 0;
}
